// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_pr.p_activity.p_view;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.*;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.Log;
import android.view.*;
import android.widget.ImageView;
import android.widget.ListAdapter;
import com.nnee.p_fk.cls_k;
import com.nnee.p_g.cls_b;
import com.nnee.p_pr.p_app.cls_PrisApp;

// Referenced classes of package com.nnee.p_pr.p_activity.view:
//            NeteaseListView, bj, af, au, 
//            bw, k

public class cls_TouchInterceptor extends cls_NeteaseListView
{

    public cls_TouchInterceptor(Context context, AttributeSet attributeset)
    {
        super(context, attributeset);
        a = false;
        v = -1;
        w = new Rect();
        D = true;
        E = -1;
        J = new cls_bj(this);
        v = context.getSharedPreferences("Music", 3).getInt("deletemode", -1);
        y = ViewConfiguration.get(context).getScaledTouchSlop();
        Resources resources = getResources();
        z = resources.getDimensionPixelSize(0x7f090000);
        B = z / 2;
        A = resources.getDimensionPixelSize(0x7f090001);
    }

    private int a(int i1)
    {
        int j1;
        int k1;
        int l1;
        j1 = 0;
        k1 = i1 - i - B;
        l1 = pointToPosition(j1, k1);
        if(l1 >= 0)
        {
            if(l1 <= g)
                l1++;
            if(a)
                Log.i("TouchInterceptor", (new StringBuilder()).append("directly return, pos ret: ").append(l1).toString());
        } else
        {
label0:
            {
                if(k1 >= getPaddingTop())
                    break label0;
                if(a)
                    Log.i("TouchInterceptor", (new StringBuilder()).append("adjustedy < getPaddingTop(), padding-top: ").append(getPaddingTop()).toString());
                l1 = 0 + getFirstVisiblePosition();
            }
        }
_L1:
        return l1;
        int i2;
        int j2;
        i2 = B;
        if(a)
            Log.w("TouchInterceptor", (new StringBuilder()).append("original-adjustedy: ").append(k1).append(", height-half: ").append(B).append(", divider-height: ").append(getDividerHeight()).append(", padding-bottom: ").append(getPaddingBottom()).append(", padding-top: ").append(getPaddingTop()).append(", step: ").append(i2).toString());
        j2 = j1;
_L3:
        k1 += i2;
        if(k1 >= q)
        {
            if(a)
                Log.i("TouchInterceptor", "adjustedy >= mHeight");
            int l2 = -1 + getChildCount();
            int k2;
            if(l2 >= 0)
                j1 = l2;
        } else
        {
label1:
            {
                if(k1 > getPaddingTop())
                    break label1;
                if(a)
                    Log.i("TouchInterceptor", "adjustedy <= getPaddingTop()");
            }
        }
_L4:
        if(j1 <= g)
            j1++;
        l1 = j1;
          goto _L1
        k2 = pointToPosition(j1, k1);
        if(a)
            Log.i("TouchInterceptor", (new StringBuilder()).append("pos: ").append(k2).append(", time: ").append(j2).toString());
        j2++;
        if(k2 < 0) goto _L3; else goto _L2
_L2:
        j1 = k2;
          goto _L4
    }

    private int a(int i1, int j1)
    {
        if(j1 >= 0) goto _L2; else goto _L1
_L1:
        int i2 = a(i1, j1 + z);
        if(i2 <= 0) goto _L2; else goto _L3
_L3:
        int l1 = i2 + -1;
_L5:
        return l1;
_L2:
        Rect rect = w;
        int k1 = -1 + getChildCount();
        do
        {
            if(k1 < 0)
                break;
            getChildAt(k1).getHitRect(rect);
            if(rect.contains(i1, j1))
            {
                l1 = k1 + getFirstVisiblePosition();
                continue; /* Loop/switch isn't completed */
            }
            k1--;
        } while(true);
        l1 = -1;
        if(true) goto _L5; else goto _L4
_L4:
    }

    private int a(ViewGroup viewgroup)
    {
        int i1 = -1;
        if(viewgroup != null) goto _L2; else goto _L1
_L1:
        return i1;
_L2:
        View view = viewgroup.findViewById(0x7f0d0056);
        if(view != null)
            i1 = view.getLeft();
        if(true) goto _L1; else goto _L3
_L3:
    }

    private void a()
    {
        for(int i1 = -1 + getChildCount(); i1 >= 0; i1--)
        {
            View view = getChildAt(i1);
            if(view != null)
            {
                android.view.ViewGroup.LayoutParams layoutparams = view.getLayoutParams();
                layoutparams.height = z;
                view.setLayoutParams(layoutparams);
                view.setVisibility(0);
            }
        }

    }

    private void a(Bitmap bitmap, int i1, int j1)
    {
        i();
        e = new android.view.WindowManager.LayoutParams();
        e.gravity = 51;
        e.x = (i1 - h) + j;
        e.y = (j1 - i) + k;
        e.height = -2;
        e.width = -2;
        e.flags = 920;
        e.format = -3;
        e.windowAnimations = 0;
        Context context = getContext();
        ImageView imageview = new ImageView(context);
        imageview.setPadding(0, 0, 0, 0);
        imageview.setImageBitmap(bitmap);
        imageview.setBackgroundDrawable(com.nnee.p_fk.cls_k.a(getContext()).b(0x7f020062));
        imageview.setAlpha(220);
        x = bitmap;
        d = (WindowManager)context.getSystemService("window");
        d.addView(imageview, e);
        c = imageview;
    }

    static void a(cls_TouchInterceptor touchinterceptor)
    {
        touchinterceptor.c();
    }

    static Handler b(cls_TouchInterceptor touchinterceptor)
    {
        return touchinterceptor.J;
    }

    private void b()
    {
        int i1;
        int j1;
        View view;
        int k1;
        i1 = f - getFirstVisiblePosition();
        if(f > g)
            i1++;
        j1 = getHeaderViewsCount();
        view = getChildAt(g - getFirstVisiblePosition());
        k1 = 0;
_L2:
        View view1;
        int l1;
        int i2;
        byte byte0;
        view1 = getChildAt(k1);
        if(view1 == null)
            return;
        l1 = z;
        if(f >= j1 || k1 != j1)
            break; /* Loop/switch isn't completed */
        android.view.ViewGroup.LayoutParams layoutparams;
        if(view1.equals(view))
        {
            i2 = l1;
            byte0 = 4;
        } else
        {
            i2 = A;
            byte0 = 0;
        }
_L3:
        layoutparams = view1.getLayoutParams();
        layoutparams.height = i2;
        view1.setLayoutParams(layoutparams);
        view1.setVisibility(byte0);
        k1++;
        if(true) goto _L2; else goto _L1
_L1:
        if(view1.equals(view))
        {
            if(f == g || getPositionForView(view1) == -1 + getCount())
            {
                i2 = l1;
                byte0 = 4;
            } else
            {
                i2 = 1;
                byte0 = 0;
            }
        } else
        if(k1 == i1 && f >= j1 && f <= -1 + getCount())
        {
            i2 = A;
            byte0 = 0;
        } else
        {
            i2 = l1;
            byte0 = 0;
        }
          goto _L3
        if(true) goto _L2; else goto _L4
_L4:
    }

    private void b(int i1)
    {
        o = q / 3;
        p = (2 * q) / 3;
    }

    private void b(int i1, int j1)
    {
        if(v == 1)
        {
            float f1 = 1F;
            int l1 = c.getWidth();
            if(i1 > l1 / 2)
                f1 = (float)(l1 - i1) / (float)(l1 / 2);
            e.alpha = f1;
        }
        if(v == 0 || v == 2)
            e.x = (i1 - h) + j;
        else
            e.x = 0;
        e.y = (j1 - i) + k;
        d.updateViewLayout(c, e);
        if(C != null)
        {
            int k1 = c.getWidth();
            if(j1 > (3 * getHeight()) / 4)
                C.setLevel(2);
            else
            if(k1 > 0 && i1 > k1 / 4)
                C.setLevel(1);
            else
                C.setLevel(0);
        }
    }

    private void c()
    {
        if(a)
            Log.i("TouchInterceptor", (new StringBuilder()).append("scroll(), mDragY: ").append(E).toString());
        if(E >= 0) goto _L2; else goto _L1
_L1:
        return;
_L2:
        int i1 = a(E);
        if(i1 < 0)
            continue; /* Loop/switch isn't completed */
        if(i1 != f)
        {
            if(l != null)
                l.a(f, i1);
            f = i1;
        }
        if(E < p) goto _L4; else goto _L3
_L3:
        if(a)
            Log.i("TouchInterceptor", "mDragY >= mLowerBound");
        if(getLastVisiblePosition() > -1 + getCount()) goto _L6; else goto _L5
_L5:
        byte byte0;
        int j1;
        View view;
        byte byte2;
        if(E > (q + p) / 2)
            byte2 = 32;
        else
            byte2 = 16;
        byte0 = byte2;
_L9:
        if(byte0 == 0)
            break; /* Loop/switch isn't completed */
        j1 = pointToPosition(0, q / 2);
        if(j1 < 0)
            j1 = h();
        view = getChildAt(j1 - getFirstVisiblePosition());
        if(view != null)
            setSelectionFromTop(j1, view.getTop() - byte0);
        continue; /* Loop/switch isn't completed */
_L6:
        if(e())
        {
            if(a)
                Log.i("TouchInterceptor", "at bottom");
            byte0 = 0;
            continue; /* Loop/switch isn't completed */
        }
          goto _L7
_L4:
        if(E <= o)
        {
            if(a)
                Log.i("TouchInterceptor", "mDragY <= mUpperBound");
            byte byte1;
            if(E < o / 2)
                byte1 = -32;
            else
                byte1 = -16;
            if(d())
            {
                if(a)
                    Log.i("TouchInterceptor", "at top");
                byte0 = 0;
            } else
            {
                byte0 = byte1;
            }
            continue; /* Loop/switch isn't completed */
        }
        if(a)
            Log.w("TouchInterceptor", "not in move range!");
_L7:
        byte0 = 0;
        if(true) goto _L9; else goto _L8
_L8:
        if(a)
            Log.e("TouchInterceptor", "deltaDistance == 0");
        if(true) goto _L1; else goto _L10
_L10:
    }

    private boolean d()
    {
        boolean flag = false;
        if(getFirstVisiblePosition() == 0 && getChildAt(flag).getTop() >= getPaddingTop())
            flag = true;
        return flag;
    }

    private boolean e()
    {
        int i1 = getLastVisiblePosition();
        boolean flag;
        if(getChildAt(i1) != null && getChildAt(i1).getBottom() > q - getPaddingBottom())
            flag = true;
        else
            flag = false;
        return flag;
    }

    private void f()
    {
        if(a)
            Log.i("TouchInterceptor", "stop thread");
        E = -1;
        if(F != null)
        {
            F.a();
            F.interrupt();
            F = null;
        }
    }

    private void g()
    {
        if(a)
            Log.i("TouchInterceptor", "start thread");
        if(F == null)
        {
            F = new cls_au(this, null);
            F.start();
        }
    }

    private int h()
    {
        int i1 = q / 2 + getDividerHeight() + z;
        int j1 = z / 10;
        int k1;
        do
        {
            k1 = pointToPosition(0, i1);
            i1 += j1;
            if(i1 >= q)
                i1 -= j1 + z;
        } while(k1 < 0);
        return k1;
    }

    private void i()
    {
        boolean flag = true;
        if(a)
            Log.i("TouchInterceptor", "stopDragging()");
        if(a)
        {
            StringBuilder stringbuilder = (new StringBuilder()).append("mDragView == null: ");
            boolean flag1;
            StringBuilder stringbuilder1;
            boolean flag2;
            StringBuilder stringbuilder2;
            if(c == null)
                flag1 = flag;
            else
                flag1 = false;
            stringbuilder1 = stringbuilder.append(flag1).append("mDragBitmap == null: ");
            if(x == null)
                flag2 = flag;
            else
                flag2 = false;
            stringbuilder2 = stringbuilder1.append(flag2).append("mTrashcan == null: ");
            if(C != null)
                flag = false;
            Log.i("TouchInterceptor", stringbuilder2.append(flag).toString());
        }
        if(c != null)
        {
            c.setVisibility(8);
            ((WindowManager)getContext().getSystemService("window")).removeView(c);
            c.setImageDrawable(null);
            c = null;
        }
        if(x != null)
        {
            x.recycle();
            x = null;
        }
        if(C != null)
            C.setLevel(0);
    }

    private void j()
    {
        k();
        H = true;
    }

    private void k()
    {
        int i1 = f - getFirstVisiblePosition();
        if(f > g)
            i1++;
        View view = getChildAt(i1);
        if(view != null)
        {
            G = view;
            android.view.ViewGroup.LayoutParams layoutparams = G.getLayoutParams();
            layoutparams.height = A;
            G.setLayoutParams(layoutparams);
        }
    }

    private void l()
    {
        if(G != null)
        {
            android.view.ViewGroup.LayoutParams layoutparams = G.getLayoutParams();
            layoutparams.height = z;
            G.setLayoutParams(layoutparams);
            G = null;
        }
    }

    public void a(Drawable drawable)
    {
        C = drawable;
        v = 2;
    }

    public void a(af af1)
    {
        l = af1;
    }

    public void a(bw bw1)
    {
        m = bw1;
    }

    public void a(com.nnee.p_pr.p_activity.p_view.cls_k k1)
    {
        n = k1;
    }

    public void a(boolean flag)
    {
        D = flag;
    }

    protected void dispatchDraw(Canvas canvas)
    {
        super.dispatchDraw(canvas);
        int i1;
        Bitmap bitmap;
        Bitmap bitmap1;
        if(getContext().getPackageName().equals(cls_PrisApp.a().A()))
            i1 = 0x7f020064;
        else
            i1 = 0x7f020065;
        bitmap = BitmapFactory.decodeResource(getResources(), i1);
        bitmap1 = Bitmap.createScaledBitmap(bitmap, canvas.getWidth(), bitmap.getHeight(), false);
        bitmap.recycle();
        canvas.drawBitmap(bitmap1, 0F, 0F, null);
    }

    public int getSolidColor()
    {
        return com.nnee.p_fk.cls_k.a(getContext()).c(0x7f080116);
    }

    public boolean onInterceptTouchEvent(MotionEvent motionevent)
    {
        if(D) goto _L2; else goto _L1
_L1:
        boolean flag;
        com.nnee.p_g.cls_b.e("TouchInterceptor", "set to could not drag and re-order, ignore intercept touch gesture.");
        flag = super.onInterceptTouchEvent(motionevent);
_L7:
        return flag;
_L2:
        com.nnee.p_g.cls_b.e("TouchInterceptor", (new StringBuilder()).append("onInterceptTouchEvent(), action: ").append(motionevent.getAction()).toString());
        if(l == null && m == null) goto _L4; else goto _L3
_L3:
        motionevent.getAction();
        JVM INSTR tableswitch 0 0: default 88
    //                   0 98;
           goto _L5 _L6
_L5:
        flag = super.onInterceptTouchEvent(motionevent);
          goto _L7
_L6:
        int i1;
        int j1;
        int k1;
        i1 = (int)motionevent.getX();
        j1 = (int)motionevent.getY();
        k1 = pointToPosition(i1, j1);
        if(k1 == -1 || k1 == -1 + getAdapter().getCount()) goto _L5; else goto _L8
_L8:
        ViewGroup viewgroup;
        int l1;
        viewgroup = (ViewGroup)getChildAt(k1 - getFirstVisiblePosition());
        h = i1 - viewgroup.getLeft();
        i = j1 - viewgroup.getTop();
        j = (int)motionevent.getRawX() - i1;
        k = (int)motionevent.getRawY() - j1;
        l1 = a(viewgroup);
        if(l1 <= 0 || i1 <= l1) goto _L10; else goto _L9
_L9:
        viewgroup.setDrawingCacheEnabled(true);
        a(Bitmap.createBitmap(viewgroup.getDrawingCache()), i1, j1);
        f = k1;
        g = f;
        q = getHeight();
        b(j1);
        flag = false;
          goto _L7
_L10:
        com.nnee.p_g.cls_b.f("TouchInterceptor", "drag down point is not in the process touch domain, ignore");
        i();
          goto _L5
_L4:
        com.nnee.p_g.cls_b.d("TouchInterceptor", "mDragListener is null and mDropListener is null!");
          goto _L5
    }

    public boolean onTouchEvent(MotionEvent motionevent)
    {
        boolean flag = true;
        if(D) goto _L2; else goto _L1
_L1:
        com.nnee.p_g.cls_b.e("TouchInterceptor", "set to could not drag and re-order, ignore touch gesture.");
        flag = super.onTouchEvent(motionevent);
_L4:
        return flag;
_L2:
        com.nnee.p_g.cls_b.e("TouchInterceptor", (new StringBuilder()).append("onTouchEvent(), action: ").append(motionevent.getAction()).toString());
        if((l != null || m != null) && c != null)
        {
            int i1 = (int)motionevent.getX();
            int j1 = (int)motionevent.getY();
            int k1 = motionevent.getAction();
            switch(k1)
            {
            case 0: // '\0'
                E = j1;
                break;

            case 1: // '\001'
            case 3: // '\003'
                if(a)
                    Log.i("TouchInterceptor", (new StringBuilder()).append("action: ").append(k1).toString());
                f();
                i();
                if(a)
                {
                    StringBuilder stringbuilder = (new StringBuilder()).append("mDropListener == null: ");
                    int l1;
                    boolean flag1;
                    if(m == null)
                        flag1 = flag;
                    else
                        flag1 = false;
                    Log.i("TouchInterceptor", stringbuilder.append(flag1).append(", mDragPos: ").append(f).append(", getCount(): ").append(getCount()).append(", mSrcDragPos: ").append(g).append(", getAdapter().getCount(): ").append(getAdapter().getCount()).toString());
                }
                if(m != null && f >= 0 && f < getCount() && g < -1 + getAdapter().getCount())
                {
                    m.a(g, f);
                    l1 = (int)motionevent.getY() - i;
                    setSelectionFromTop(f, l1);
                } else
                if(g == -1 + getAdapter().getCount())
                    setAdapter(getAdapter());
                break;

            case 2: // '\002'
                b(i1, j1);
                E = j1;
                g();
                break;
            }
        } else
        {
            flag = super.onTouchEvent(motionevent);
        }
        if(true) goto _L4; else goto _L3
_L3:
    }

    private static final String b = "TouchInterceptor";
    private static final int r = 0;
    private static final int s = 1;
    private static final int t = 2;
    private static final int u = 4;
    private int A;
    private int B;
    private Drawable C;
    private boolean D;
    private int E;
    private au F;
    private View G;
    private boolean H;
    private Runnable I;
    private Handler J;
    private boolean a;
    private ImageView c;
    private WindowManager d;
    private android.view.WindowManager.LayoutParams e;
    private int f;
    private int g;
    private int h;
    private int i;
    private int j;
    private int k;
    private cls_af l;
    private cls_bw m;
    private com.nnee.p_pr.p_activity.p_view.cls_k n;
    private int o;
    private int p;
    private int q;
    private int v;
    private Rect w;
    private Bitmap x;
    private final int y;
    private int z;
}
